# Maintainer:
pkgname=simpleble
pkgver=0.6.1
pkgrel=1
pkgdesc="Cross-platform library for bluetooth low-energy"
url="https://github.com/OpenBluetoothToolbox/SimpleBLE"
arch="all"
license="MIT"
makedepends="
	cmake
	dbus-dev
	fmt-dev
	samurai
	"
subpackages="
	$pkgname-dev
	libsimpleble:lib
	libsimpleble-c:lib_c
	libsimplebluez:lib_bluez
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/OpenBluetoothToolbox/SimpleBLE/archive/refs/tags/v$pkgver.tar.gz
	bluez.patch
	fmt.patch
	"
builddir="$srcdir/SimpleBLE-$pkgver"
options="!check" # tests require plain

build() {
	cmake -B build-ble -G Ninja -S simpleble \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DLIBFMT_VENDORIZE=OFF
	cmake --build build-ble
	cmake -B build-bluez -G Ninja -S simplebluez \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DLIBFMT_VENDORIZE=OFF
	cmake --build build-bluez
}

package() {
	DESTDIR="$pkgdir" cmake --install build-ble
	DESTDIR="$pkgdir" cmake --install build-bluez
}

lib() {
	amove usr/lib/libsimpleble.so.*
}

lib_c() {
	amove usr/lib/libsimpleble-c.so.*
}

lib_bluez() {
	amove usr/lib/libsimplebluez.so.*
}

sha512sums="
bf9b166340df6620fcafe7e453795bc314769aed49c5284b425ea90b064a9d242432625f544ea6f79441e36c1b9ed5909dfc80d1e69c102ce27589cc09f02417  simpleble-0.6.1.tar.gz
3bf34d51bb267077af537eaf6fec54c9049c0a3f85e4724afad76c7ba3d0ed3be73dcc96bc7d69ddcdfb40a823bd236970880e0c4439b9e70283af53e8cbc085  bluez.patch
b1520b22a7fa98e552b67b87787cbceaf0f04122b36001b0566159206b724f7ff947869f4cc06e4e4831e6286c468bf77eb5c0eefae99818d58baf87b6c944f7  fmt.patch
"
